<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>The as12 assembler</TITLE>
<BODY text=#000000 vLink=#551a8b aLink=#ff0000 link=#0000ff bgColor=#ffffff>
<H1>The as12 assembler</H1>
<UL>
  <LI><A href="#introduction">Introduction</A> 

  <LI><A href="#invoke">Invoking the as12 assembler</A> 
  <LI><A href="#commandline">Command-line options</A> 
  <LI><A href="#Files">Files</A> 

  <LI><A href="#as12 constructs">as12 constructs</A> </LI></UL>

<P>Version 1.2: 8 July 1996 by Karl Lunt, <A href="http://www.seanet.com/~karllunt"> http://www.seanet.com/~karllunt</A> </P>
<P>Version 1.2a: 7 April 1999 by Tom Almy, <A href="http://www.aracnet.com/~tomalmy">http://www.aracnet.com/~tomalmy</A> 
<P>Version 1.2b: 18 January 2003 by Eric Engler, <a href="http://www.geocities.com/SiliconValley/Network/2114/">
http://www.geocities.com/SiliconValley/Network/2114/</a><P>Version 1.2c: 29 January 2003 by Eric Engler, <a href="http://www.geocities.com/SiliconValley/Network/2114/">
http://www.geocities.com/SiliconValley/Network/2114/</a><P>Version 1.2d: 29 
March 2003 by Eric Engler, <a href="http://www.geocities.com/SiliconValley/Network/2114/">
http://www.geocities.com/SiliconValley/Network/2114/</a><HR>

<A name=introduction></A>
<P></P>
<H2>Introduction</H2>
<P>The as12 assembler is a two-pass cross-assembler for the Motorola 68hc12 
microcontroller (MCU). as12 was written in C and derived from the source code 
for the original asm11 68hc11 assembler. So far, as12 has been ported to Sun 
Sparcstations, HPs, IBM PC-compatibles, and Apple Macintoshes.</P>
<P>as12 was designed to run from a command-line interpreter (CLI), so it works 
well with DOS batch files and Unix shell scripts. The Mac version of as12 has 
been integrated with the Macintosh Programmer's Workbench (MPW).</P>
<P>Unless otherwise noted, this document describes the PC version of as12.</P>
<P>Additional changes by Tom Almy corrects documentation, adds a unary 
complement operator, and provides a Windows console mode compiler which handles 
long file names.
<HR>
<A name="as12 constructs">
<P></P>
<H2>as12 constructs</H2></A>
<P>
<UL>
  <LI><A 
  href="#commandline">Command-line 
  Options</A> 
  <LI><A 
  href="#directives">Directives</A> 

  <LI><A 
  href="#pound operators">Pound 
  Sign (#) Operators</A> 
  <LI><A 
  href="#mnemonics">Mnemonics</A> 

  <LI><A 
  href="#comments">Comments</A> 

  <LI><A 
  href="#expressions">Expressions</A> 
  </LI></UL>
<P>
<HR>
<A name=invoke>
<H2>Invoking the as12 assembler</H2></A>
<P>To start the as12 assembler, enter the following command at the prompt:</P><PRE>as12 file.ext</PRE>
<P>where file.ext is the path, name, and extension of the file you want to 
assemble. The as12 assembler will assemble the file, sending the listing output 
to the console and writing the S19 object output to a file named m.out. To save 
the listing output in a text file for later review, use the -L option. For 
example:</P><PRE>as12 foo.asm -Lfoo.lst</PRE>
<P>will assemble the file foo.asm and write the output listing to a file named 
foo.lst.</P>
<P>Entering <STRONG>as12</STRONG> with no arguments will display a short help 
file describing the available command-line options.
<HR>
<A name=commandline>
<P></P>
<H2>Command-line Options</H2></A>
<P>Command-line options allow you to specify input file names, define global 
symbols, and declare paths for library files. For example:</P><PRE>as12 -dTIMERS -l\mylib\hc12 foo -L</PRE>
<P>will assemble the file foo.asm, using the library files found in the 
directory \mylib\hc12. Additionally, the label TIMERS will be defined with a 
value of 1 and the listing output will be written to file foo.lst.</P>
<P>When specifying the assembler source file, the extension ".asm" is assumed if 
no extension is explicitly given. If more than one source file is specified, 
then they will be read in the order listed.</P>
<P>The full set of command-line options includes:</P>
<UL>
  <LI><A 
  href="#-d">-d</A> 
  Define a label 
  <LI><A 
  href="#-l">-l</A> 
  Define a library path 
  <LI><A 
  href="#-p">-p</A> 
  Define a target processor type 
  <LI><A 
  href="#-D">-D</A> 
  Turn on debugging output 
  <LI><A 
  href="#-L">-L</A> 
  Specify a list file </LI></UL>
<P>
<HR>
<A name=-d>
<H2>-d Define a label</H2></A>
<P>The -d option allows you to define a label on the command line. Labels 
defined in this manner are treated by the as12 assembler as if they had been 
defined within your source file and assigned a value of 1. Your source file can 
then refer to these labels in <A 
href="#pound operators">#ifdef</A> 
tests. For example:</P>
<P>as12 -dMY_ALGORITHM myprog.asm</P>
<P>causes the as12 assembler to behave as if your source file began with the 
line:</P>
<P>#define MY_ALGORITHM</P>
<P>This ability to define labels from the command line adds great power to the 
as12 assembler. You can use this feature to selectively assemble blocks of 
source code based on arguments you specify in the command line, without first 
having to edit the source code before each assembly.
<HR>
<A name=-l>
<P></P>
<H2>-l Define a library path</H2></A>
<P>Normally, as12 first checks in the current directory for needed source and 
include files. If as12 cannot find a needed file in the current directory, it 
then checks the path for a previous source file and searches that directory. If 
that search also fails, as12 will use the library path specified with the -l 
option on the command line, if any. For example:</P><PRE>as12  -lc:\mypath  myfile.asm</PRE>
<P>
<HR>
<A name=-p>
<H2>define part string</H2></A>
<P>as12 allows you to pass in a special string which will identify the part you 
are compiling the program for. When combined with the <A 
href="#ifpa rt">#ifpart</A> 
conditional assembly directive, can give users a powerful way to compile source 
code which may depend upon what part is being targete d.</P>
<P>An illustration of it usage...</P><PRE>as12 -pb32
</PRE>
<P>
<HR>
<A name=-D>
<H2>debug</H2></A>
<P>Turns on the internal debug features of as12. Mostly for the developer of 
as12, but may help you if you are having a problem.</P><PRE>as12 -d source_file
</PRE>
<P>
<HR>
<A name=-L>
<H2>listing</H2></A>
<P>Specifies a listing file. If no filename extension is given, ".lst" is 
assumed. If no file name is given, then the file name will be that of the first 
source file, with an extension ".lst".
<HR>
<A name=-h>
<H2>help</H2></A>
<P>This help is designed as a reminder to the other command line options. </P>
<P>Example...</P><PRE>as12 -h
</PRE>
<P>
<HR>
<A name="pound operators">
<H1>Pound Sign (#) Operators</H1></A>
<P>
<UL>
  <LI><A 
  href="#include">#include</A> 

  <LI><A 
  href="#define">#define</A> 

  <LI><A 
  href="#ifeq">#ifeq</A> 

  <LI><A 
  href="#ifneq">#ifneq</A> 

  <LI><A 
  href="#ifdef">#ifdef</A> 

  <LI><A 
  href="#ifpart">#ifpart</A> 

  <LI><A 
  href="#else">#else</A> 

  <LI><A 
  href="#endif">#endif</A> 

  <LI><A 
  href="#typical conditional assembly">Typical 
  Conditional Assembly Examples</A> </LI></UL>
<P>
<HR>
<A name=include>
<H1>#include</H1></A>
<P>The include directive allows other assembly source files to be inserted in 
the code immediately after the include statement, <EM>as if</EM> the contents 
of the included file were actually in the file that contained the include 
statement. Stated differently, the include statement works as you might expect. 
The syntax of the include statement is shown below...</P><PRE>#include \my_dir\myfile.asm</PRE>
<P><font face="Times New Roman">In Unix, it is important to note that the filename expansion will only be as good as 
the filename expansion as the shell that you are operating in. For ex ample, if 
you are running shell (/bin/sh) then the tilde username (~user) lookup may not 
work correctly. It is best to put in relative or absolute filepath 
specifications that are not shell dependent.</font></P>
<P>include statements may be used within <A 
href="#define">#ifdef</A> 
statements.
<P>New in version 1.2c: we can now support quoted filenames. This lets us use 
filenames that might have embedded spaces, or the directory name may have 
embedded spaces:<P>#include &quot;<a href="file:///c:/program%20files/as12/my%20defs.h">c:\program 
files\as12\my defs.h</a>&quot;<P>&nbsp;<HR>
<A name=define>
<P></P>
<H1>#define</H1></A>
<P>The define statement allows labels to be defined. This statement is simply an 
alternate form for an <A 
href="#equ">equ</A> 
assembler directive. T he alternate form is provided so that users will be 
alerted to the opportunities to write more sophisticated code that the <A 
href="#ifeq">#ifeq</A>, 
and related statements allow. The proper use of the define statement is...</P><PRE>#define <A href="#symbols">MY_LABEL</A> <A href="#expressions">expression</A>
</PRE>
<P>The define statement is as if the user had typed the following...</P><PRE><A href="#labels">MY_LABEL</A>  <A href="#equ">EQU</A>  <A href="#expressions">expression</A>
</PRE>
<P>Both forms are equally valid, and both forms are implemented internally thee 
same way. The EQU is probably more portable of the two constructs.
<HR>
<A name=ifeq>
<P></P>
<H1>#ifeq</H1></A>
<P>The ifeq command allows for the user to conditionally compile different 
sections of assembly language based on whether or not a label is equal to a 
value. Example...</P><PRE>#ifeq <A href="#symbols">MY_SYMBOL</A>  <A href="#expressions">expression_to_compare_to</A>
	... (this code will be executed if MY_SYMBOL has the same value as
the expression_to_compare_to)
	...
<A href="#endif">#endif</A>
</PRE>
<P>I show the <A 
href="#endif">#endif</A> 
statement because for every form of <EM>if</EM> there needs to be a marker so 
that as12 knows what code is to be conditionally compiled. Restated, for every 
if there needs to be an endif.</P>
<P>If the expression resolves to the same value as the label in an #ifeq 
directive, then every line between the #ifeq and the #endif is executed. If the 
expression resolves to a different value than the label, all of the lines 
between the #ifeq and the #endif are ignored.
<HR>
<A name=ifneq>
<P></P>
<H1>#ifneq</H1></A>
<P>The ifneq command allows for the user to conditionally compile different 
sections of assembly language based on whether or not a label is not equ al to a 
value. Example...</P><PRE>#ifneq <A href="#symbols">MY_LABEL</A>  <A href="#expressions">expression_to_compare_to</A>
	... (this code will be executed if MY_LABEL has a different value
as the expression_to_compare_to)
	...
<A href="#endif">#endif</A>
</PRE>
<P>I show the <A 
href="#endif">#endif</A> 
statement because for every form of <EM>if</EM> there needs to be a marker so 
that as12 knows what code is to be conditionally compiled. Restated, for every 
if there needs to be an endif.</P>
<P>If the expression resolves to the same value as the label in an #ifeq 
directive, then every line between the #ifeq and the #endif is ignored. If the 
expression resolves to a different value than the label, all of the lines 
between the #ifeq and the #endif are executed.
<HR>
<A name=ifdef>
<P></P>
<H1>#ifdef</H1></A>
<P>The ifdef command allows for the user to conditionally compile different 
sections of assembly language based on whether or not a label is defined (via a 
<A 
href="#define">#define</A> 
or an <A 
href="#equ">EQU</A>. 
Example...</P><PRE>#ifdef <A href="#symbols">MY_LABEL</A> 
	... (this code will be executed if MY_LABEL has been defined)
	...
<A href="#endif">#endif</A>
</PRE>
<P>I show the <A 
href="#endif">#endif</A> 
statement because for every form of <EM>if</EM> there needs to be a marker so 
that as12 knows what code is to be conditionally compiled. Restated, for every 
if there needs to be an endif.</P>
<P>If the label in an #ifdef directive is defined, then every line between the 
#ifeq and the #endif is executed. If the label is not defined, all o f the lines 
between the #ifdef and the #endif are ignored.
<HR>
<A name=ifpart>
<P></P>
<H1>#ifpart</H1></A>
<P>This is the only directive that allows for a string comparison. A special 
internal variable is the only variable which is a string variable. The only way 
to set that variable is with the <A 
href="#-p">-p</A> 
command line option. The sole purpose of this directive is to allow for 
conditional as sembly based upon the value of the string. This seemed natural 
for handling the different part types. Example...</P><PRE>#ifpart b32
  ... (assembly code) (will be executed if the string &lt;b32&gt; is same as
string in <A href="#-p">-p</A> option
  ...
<A href="#endif">#endif</A>
</PRE>
<P>I show the <A 
href="#endif">#endif</A> 
statement because for every form of <EM>if</EM> there needs to be a marker so 
that as12 knows what code is to be conditionally compiled. Restated, for every 
if there needs to be an endif.</P>
<P>If the string that follows the #ifpart directive matches the string that was 
passed in via the <A 
href="#-p">-p</A> 
option, then the lines betwee n the #ifpart and the #endif will be executed. If 
the strings do not match, the lines between the #ifpart and the #endif will be 
ignored.
<HR>
<A name=else>
<P></P>
<H1>#else</H1></A>
<P>This directive must be coupled with any of the if directives. This allows 
either or compilation and performs just like you expect an else to perf orm. 
Example...</P><PRE>#ifdef <A href="#symbols">MY_LABEL</A>
	... (assembly code) (will be executed if MY_LABEL is defined)
#else
	... (assembly code) (will be executed if MY_LABEL is NOT defined)
#endif
</PRE>
<P>I show the <A 
href="#endif">#endif</A> 
statement because for every form of <EM>if</EM> there needs to be a marker so 
that as12 knows what code is to be conditionally compiled. Restated, for every 
if there needs to be an endif. </P>
<P>If the if statement that goes with the else statement is true, the statements 
between the if and the else will be assembled, and the statements b etween the 
else and the endif will be ignored. If the if statement is false, the statements 
between the if and the else will be ignored and the state ments between the else 
and the endif will be executed.</P>
<P>There can only be one else for each if statement.
<HR>
<A name=endif>
<P></P>
<H1>#endif</H1></A>
<P>The endif statement tells the assembler when the conditional assembly section 
of the code is finished. Otherwise the assembler would have no way of knowing 
when to quit.</P>
<P>For every if statement there needs to be one endif. If there is an if and an 
else, then there should be one end statement also.</P>
<P>Examples...</P><PRE>#ifpart part_name
#else
#endif

#ifndef <A href="#symbols">MY_LABEL</A>
#endif

#ifndef <A href="#symbols">MY_LABEL</A>
#else
#endif
</PRE>
<P>
<HR>
<A name="typical conditional assembly">
<H2>Typical Conditional Assembly Examples</H2></A>
<P>
<UL>
  <LI>Use to handle parts starting in different modes. You can automate this and 
  keep from modifying your source code my defining the label by invokin e the 
  assembler using the <A 
  href="#-d">-d</A> 
  command line option. </LI></UL><PRE><A href="#ifdef">#ifdef</A> <A href="#symbols">EXPANDED_MODE</A>
	<A href="#org">org</A> <A href="#symbols">START_OF_EXTERNAL_RAM_TESTS</A>
<A href="#else">#else</A>
	<A href="#org">org</A>	<A href="#symbols">START_OF_FLASH_RAM</A>
<A href="#endif">#endif</A>


<UL>
  <LI>&nbsp;</LI></UL></PRE>Use to handle configuring software so that your code will 
operate regardless of what part might be used. You can keep from changing your 
source code by passing in the parttype using the <A 
href="#-p">-p</A> 
command line option. 
<UL></UL><PRE><A href="#ifpart">#ifpart</A> b32
<A href="#labels">RAM_START</A>	<A href="#equ">EQU</A>	$800
FEE_START	EQU	$8000
REG_START	EQU	$0000
PWM_START	EQU	$c7
#endif

<A href="#ifpart">#ifpart</A> a4
<A href="#labels">RAM_START</A>	<A href="#equ">EQU</A>	$600
REG_START	EQU	$0100
#endif
</PRE>
<P>Notice how easy you could build a library of different parts and make your 
source code compile accordingly.</P>
<P>
<HR>
<A name=Files>
<H1>Files</H1></A>
<P>
<UL>
  <LI><A 
  href="#as12exe">as12.exe</A> 

  <LI><A 
  href="#m.out">?.s19</A> 

  <LI><A 
  href="#the source">the 
  source file(s)</A> 
  <LI><A 
  href="#the listing">the 
  listing</A> </LI></UL>
<P>
<HR>
<A name=as12exe>
<H1>as12.exe</H1></A>
<P>This executable file was created with Borland C++ version 5.0, targeting the 
Win32 Console.
<HR>
<A name=m.out>
<P></P>
<H1>?.s19</H1></A>
<P>A file with the same name as the first source file but with the extension 
".s19" is always produced by the assembler. It cannot be suppressed. It is the 
s-records that are created by assembling the source file that is given to as12 
on the as12 command line.</P>
<P><EM>99 times out of 100 times</EM>, this is the file of interest when using 
the assembler. </P>
<P>For information regarding s-records (like a spec, but not quite) go <A 
href="http://www.ecse.rpi.edu/Courses/CStudio/hc12sim/srecord.html">my little 
s-record description</A>.
<HR>
<A name="the listing">
<P></P>
<H1>the listing</H1></A>
<P>The listing file is useful for debugging. Simply add the command line option 
"-L" to create the listing file.
<HR>
<A name="the source">
<H1>the source file(s)</H1></A>
<P>Standard ASCII source files. These should be created with the extension 
".asm" since that is the default used by the assembler.
<HR>
<A name=features></A>
<H1>Features</H1>
<P>
<HR>
<A name=directives>AS12 Directives (or pseudo-opcodes)</A> 
<P></P>
<UL>
  <LI><A 
  href="#bsz">bsz</A> 
  <LI><A 
  href="#db">db</A> 
  <LI><A 
  href="#dc.b">dc.b</A> 

  <LI><A 
  href="#dc.w">dc.w</A> 

  <LI><A 
  href="#ds">ds</A> 
  <LI><A 
  href="#ds.b">ds.b</A> 

  <LI><A 
  href="#ds.w">ds.w</A> 

  <LI><A 
  href="#dw">dw</A> 
  <LI><A 
  href="#end">end</A> 
  <LI><A 
  href="#equ">equ</A> 
  <LI><A 
  href="#fcb">fcb</A> 
  <LI><A 
  href="#fcc">fcc</A> 
  <LI><A 
  href="#fdb">fdb</A> 
  <LI><A 
  href="#fill">fill</A> 

  <LI><A 
  href="#loc">loc</A> 
  <LI><A 
  href="#nam">nam</A> 
  <LI><A 
  href="#name">name</A> 

  <LI><A 
  href="#opt">opt</A> 
  <LI><A 
  href="#org">org</A> 
  <LI><A 
  href="#pag">pag</A> 
  <LI><A 
  href="#page">page</A> 

  <LI><A 
  href="#redef">redef</A> 

  <LI><A 
  href="#rmb">rmb</A> 
  <LI><A 
  href="#rmw">rmw</A> 
  <LI><A 
  href="#spc">spc</A> 
  <LI><A 
  href="#ttl">ttl</A> 
  <LI><A 
  href="#zmb">zmb</A> 
  </LI></UL>
<P>
<HR>
<A name=expressions>
<H2>Expressions</H2></A>
<P>Expressions may consist of <A 
href="#Symbols">symbols</A>, 
<A 
href="#constants">constants</A> 
or the character '*' (denoting the current value of the 
program counter) joined together by one of the operators: +-*/%&amp;|^. You may nest 
expressions using parentheses up to 10 levels deep. The operators are the same as 
in C:</P><PRE>+       add
-       subtract
*       multiply
/       divide
%       remainder after division
&amp;       bitwise and
|       bitwise or
^       bitwise exclusive-or</PRE>
<P>In addition, the unary minus (-) and complement (~) operators are allowed 
when preceding a symbol, constant, or character '*' only.</P><PRE>Examples of valid expressions...

(5*8)
(<A href="#symbols">my_val</A>-10+20*(16-label)/10)
10
$10
*
%10010
<A href="#symbols">my_value</A>
~$20</PRE>
<PRE><font face="Times New Roman" size="3">Starting with version 1.2c you can have spaces in an expression:</font></PRE>
<PRE>	ldaa foo + 1</PRE>
<P>Note: When the asterisk (*) is used in a context where the as12 is expecting 
a label, the asterisk (*) represents the value of the current program counter.
<HR>

<P></P>
<H2><A name=Symbols></A>Symbols</H2>
<P>Symbols consist of one or more characters where the first character is 
alphabetic and any remaining characters are alphanumeric. Symbol are case 
sensitive.</P>
<P><A name=constants>
<HR>

<P></P>
<H2>Constants</H2></A>
<P>Constants are constructed with the same syntax as the Motorola MDOS assembler 
(oh, now thats a real useful piece of information - hey I just copied this 
anyway):</P><PRE> 
'       followed by ASCII character
$       followed by hexadecimal constant
@       followed by octal constant
%       followed by binary constant
digit   decimal constant

</PRE>
<P>
<HR>
<A name=labels>
<H2>Labels</H2></A>
<P>A symbol starting in the first column is a label and may optionally be ended 
with a ':'. A label may appear on a line by itself and is then interpreted 
as:</P><PRE>        Label   EQU     *</PRE>
<P>Note that labels are case sensitive. "Label" and "label" are different 
labels. </P>
<P>
<HR>
<A name=comments>
<H2>Comments</H2></A>
<P>Here are some notes about comments...</P>
<UL>
  <LI>Any line beginning with an * is a comment 
  <LI>Any line beginning with a ; is a comment 
  <LI><EM>You must </EM>have a ; (semi-colon) prefixing any comment on a line 
  with mnemonics </LI></UL>
<P>
<HR align=left width="100%">
<A name=bsz>The bsz PSEUDO OPCODE
<P></P></A>
<H3>Name: Block Set Zeros</H3>
<H3>Description:</H3>
<P>Zeros memory. Please use zmb instead. </P>
<P>Actually, don't use these at all.
<HR>
<A name=db>
<P></P>
<H2>The db PSEUDO OPCODE</H2></A>
<H3>Name: Define Byte</H3>
<H3>Syntax and examples (maybe):</H3><PRE>	db	Byte_Definition[,Byte_Definition]

	db	$55,$66,%11000011
	db	10

half	db	0.5*100
</PRE>
<H3>Description:</H3>
<P>Defines the value of a byte or bytes that will be placed at a given 
address.</P>
<P>The db directive assigns the value of the expression to the current program 
counter. Then the program counter is incremented.</P>
<P>Multiple bytes can be defined at a time by comma separating the arguments. 
Each comma separated argument can be a separate expression that the as 12 will 
evaluate. </P>
<H3>Notes:</H3>
<UL>
  <LI>This is probably a more universally accepted pseudo-op than the fcb. 
  However, the selection of a pseudo op does have implications on portability. I 
  provide as many as I can to enhance OUR ability to read other peoples code. 
  <LI>This should be used for memory that is not considered volatile 
  (ROM/EE/FLASH) or memory that will be boot-loaded or similar. For defining RAM 
  memory for variables and scratchpad memory the ds directive is more 
  appropriate. </LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>fcb 
  <LI>fdb 
  <LI>dw 
  <LI>ds </LI></UL>
<H3>Useful With:</H3>
<UL>
  <LI>Defining Data Tables/Structures 
  <LI>Defining ASCII phrases (strings) 
  <LI>Defining Constants </LI></UL>
<H3>Things to look out for:</H3>
<UL>
  <LI>Be careful not to define values that are <EM>larger</EM> than 8 bits. as12 
  truncates the left most bits to make the byte fit into a byte. 
  <LI>A label is usually used so there is a reference to this memory. In the 
  last example in the Syntax section, it can be seen that the label 
  <EM>half</EM> will refer to the byte with a decimal value of 50. (Not really 
  fixed point math but I'm only demonstrating the use of a label) </LI></UL>
<P>
<HR>
<A name=dc.b>
<H2>The dc.b PSEUDO OPCODE</H2></A>
<H3>Name: Define Constant Byte</H3>
<H3>Description:</H3>
<P>Identical to db. My preference is to use the db and not this one. This is 
only to help read other peoples software that may get sent to us.
<HR>
<A name=dc.w>
<P></P>
<H2>The dc.w PSEUDO OPCODE</H2></A>
<H3>Name: Define Constant Word</H3>
<H3>Description:</H3>
<P>Identical to dw.
<HR>
<A name=ds>
<P></P>
<H2>The ds PSEUDO OPCODE</H2></A>
<H3>Name: Define Storage</H3>
<H3>Syntax and examples (maybe):</H3><PRE>	ds	Number_of_Bytes_To_Advance_Program_Counter
</PRE>
<H3>Description:</H3>
<P>The ds increments the program counter by the value indicated in the Number of 
Bytes argument.</P>
<H3>Notes:</H3>
<UL>
  <LI>This is the preferred method of defining a memory location whose value... 
  <UL>
    <LI>is changing 
    <LI>is generally not known </LI></UL>
  <LI>In other words, this is optimal for defining RAM or REGISTER spaces. The 
  reason for this is the ease in which a ds based region can be relocated . 
</LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>rmb </LI></UL>
<H3>Useful With:</H3>
<UL>
  <LI>RAM definitions 
  <LI>REGISTER definitions </LI></UL>
<H3>Things to look out for:</H3>
<UL>
  <LI>Inappropriate for non-volatile memory definitions </LI></UL>
<P>
<HR>
<A name=ds.b>
<H2>The ds.b PSEUDO OPCODE</H2></A>
<H3>Name: Define Storage Bytes</H3>
<H3>Description:</H3>
<P>Identical to ds. I don't care what form that you use, but I imagine that the 
ds is better than the ds.b. I hope you don't mind <EM>clicking</EM> one more 
time to get to the right spot in the manual.
<HR>
<A name=ds.w>
<P></P>
<H2>The ds.w PSEUDO OPCODE</H2></A>
<H3>Name: Define Storage Word</H3>
<H3>Syntax and examples (maybe):</H3><PRE>	ds.w	Number_of_Words_To_Advance_Program_Counter
</PRE>
<H3>Description:</H3>
<P>The ds.w increments the program counter by the value indicated in the Number 
of Words argument multiplied by two. In other words, if the ds.w expression 
evaluates to 4 then the program counter is advanced by 8.</P>
<H3>Notes:</H3>
<UL>
  <LI>Good for defining RAM and REGISTERS </LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>ds </LI></UL>
<H3>Useful With:</H3>
<UL>
  <LI>labels </LI></UL>
<H3>Things to look out for:</H3>
<UL>
  <LI>Inappropriate for non-volatile memory. </LI></UL>
<P>
<HR>
<A name=dw>
<H2>The dw PSEUDO OPCODE</H2></A>
<H3>Name: Define Word</H3>
<H3>Syntax and examples (maybe):</H3><PRE>	dw	Word_Definition[,Word_Definition]

	dw	$55aa,$66,%11000011
	dw	10

half	dw	0.5*65536
</PRE>
<H3>Description:</H3>
<P>Defines the value of a word or words that will be placed at a given 
address.</P>
<P>The dw directive assigns the value of the expression to the current program 
counter. Then the program counter is incremented by 2.</P>
<P>Multiple words can be defined at a time by comma separating the arguments. 
Each comma separated argument can be a separate expression that the as 12 will 
evaluate. </P>
<H3>Notes:</H3>
<UL>
  <LI>This is probably a more universally accepted pseudo-op than the fdb. 
  However, the selection of a pseudo op does have implications on portability. I 
  provide as many as I can to enhance OUR ability to read other peoples code. 
  <LI>This should be used for memory that is not considered volatile 
  (ROM/EE/FLASH) or memory that will be boot-loaded or similar. For defining RAM 
  memory for variables and scratchpad memory the ds directive is more 
  appropriate. 
  <LI>Words are right justified and left filled with zero's. </LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>fdb 
  <LI>dc.w </LI></UL>
<H3>Useful With:</H3>
<UL>
  <LI>Defining Data Tables/Structures 
  <LI>Defining Constants </LI></UL>
<H3>Things to look out for:</H3>
<UL>
  <LI>Be careful not to define values that are <EM>larger</EM> than 16 bits. 
  as12 truncates the left most bits to make the word fit into a word. </LI></UL>
<P>
<HR>
<A name=end>
<H2>The end PSEUDO OPCODE</H2></A>
<H3>Name: End</H3>
<H3>Description:</H3>
<P>Identical to ttl.
<HR>
<A name=equ>
<P></P>
<H2>The equ PSEUDO OPCODE</H2></A>
<H3>Name: Equate</H3>
<H3>Syntax and examples (maybe):</H3><PRE>Label	EQU	Value_To_Assign_To_The_Label
</PRE>
<H3>Description:</H3>
<P>Directly assigns a value to a label.</P>
<H3>Notes:</H3>
<UL>
  <LI>Very good for constants 
  <LI>Most common across different assemblers (most likely to port easily) 
</LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>#define 
  <LI>-d command line option </LI></UL>
<H3>Useful With:</H3>
<UL>
  <LI>#ifeq and related options </LI></UL>
<H3>Things to look out for:</H3>
<UL>
  <LI>Be careful of how many bits your label can take. The as12 internally uses 
  anywhere from 32 bits for the label value with the Win32 version. It is very 
  easy to get bigger than 8 or 16 bits. 
  <LI>Inappropriate for defining memory locations. I would recommend only using 
  for defining constants. Otherwise relocation can be made very difficult. 
</LI></UL>
<P>
<HR>
<A name=fcb>
<H2>The fcb PSEUDO OPCODE</H2></A>
<H3>Name: Form Constant Byte</H3>
<H3>Description:</H3>
<P>Identical to db. The db is the preferred command. This flies in the face of 
Motorola history, but I believe that <EM>externally </EM>our files may be more 
compatible (Although I can't prove it so do what you want).
<HR>
<A name=fcc>
<P></P>
<H2>The fcc PSEUDO OPCODE</H2></A>
<P>
<H3>Name: Form Constant Characters</H3>
<H3>Syntax and examples (maybe):</H3><PRE>	fcc	delim_character<EM>string_to_encode</EM>delim_character
	fcc	/my_string/
	fcc	*// string with slashes //*
	fcc	'best to use single quotes'
</PRE>
<H3>Description:</H3>
<P>FCC allow the encoding of a string. </P>
<P>The first character is the delimiter. By allowing the flexibility of 
selecting delimiters, you can easily make strings which have slashes and tick 
marks in them. The <EM>only</EM> catch is that if you choose a delimiter, it 
</P>
<UL>
  <LI>must also be used to mark the end of the string 
  <LI>it cannot appear in the string as a character. </LI></UL>
<P>In the second example, my_string will be encoded as an ASCII string. The /'s 
simply mark the ending and beginning of the string. This also lets you put 
spaces in the string.</P>
<P>In the third example, the * (asterisk) is the delimiter and the slashes will 
be encoded with their ASCII values into the ASCII string.</P>
<P>I like single quotes the best as a delimiter. You could argue that double 
quotes are even better because it follows 'C' convention.</P>
<H3>Notes:</H3>
<UL>
  <LI>You cannot have the space as a delimiter. 
  <LI>I believe that you can have strings in the FCB except that you have to 
  encode them one at a time and comma delimit them. Yuk. </LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>fcb </LI></UL>
<H3>Useful With:</H3>
<UL>
  <LI>Defining strings for displays and such. </LI></UL>
<P>
<HR>
<A name=fdb>
<H2>The fdb PSEUDO OPCODE</H2></A>
<H3>Name: Form Double Byte</H3>
<H3>Description:</H3>
<P>Identical to dw. I prefer the dw usage.
<HR>
<A name=fill>
<P></P>
<H2>The fill PSEUDO OPCODE</H2></A>
<H3>Name: Fill Memory</H3>
<H3>Syntax and examples (maybe):</H3><PRE>	fill	byte_to_fill_memory_with,num_of_bytes_to_fill
</PRE>
<H3>Description:</H3>
<P>FILL allows a user to fill memory with a byte. See my comments in zmb about 
the value of these pseudo opcodes.</P>
<H3>Notes:</H3>
<UL>
  <LI>Nice for initializing memory. </LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>zmb </LI></UL>
<H3>Useful With:</H3>
<UL>
  <LI>Debugging 
  <LI>Filling unused non-volatile memory with a <EM>safe</EM> opcode when the 
  processor gets lost. </LI></UL>
<H3>Things to look out for:</H3>
<UL>
  <LI>Since RAM memory, by definition, cannot be initialized, this command has 
  little use. This is because you must DOWNLOAD the s-records to make the 
  clearing take place. Only in systems which have some sort of bootstrapping 
  (where s-records are downloaded) would this be very useful. If you are 
  clearing memory, you should probably count on routines to do it for you. 
</LI></UL>
<P>
<HR>
<A name=loc>
<H2>The loc PSEUDO OPCODE</H2></A>
<P>Another Pseudo OP called LOC basically increments and produces an internal 
counter used in conjunctions with the backwards tick mark (`). By using LOC's 
and the ` mark you can do code like the following without worrying about 
thinking up new labels.</P><PRE>        LOC
        ldaa    #1
loop`
        deca
        bra     loop`
        LOC
loop`
        brset   0,x $55 loop`

</PRE>
<P>This code will work perfectly fine because the second loops label is really 
loop002 and the first ones is loop001. The assembler really sees this...</P><PRE> 
        LOC
        ldaa    #1
loop001
        deca
        bra     loop001
        LOC
loop002
        brset   0,x $55 loop002

</PRE>
<P>You may also seed the LOC with a valid expression or number by putting that 
expression or number in the operand field. This gives you the ability to over 
ride the automatic numbering. This is also sometimes handy if you need to keep 
track of what your local variable is. (you lose track in the source if you 
aren't careful, because the tick ' mark is the only thing you see).
<HR>
<A name=nam></A><A name=name>
<P></P>
<H2>The name PSEUDO OPCODE</H2></A>
<H3>Name: <EM>N</EM>ot <EM>A</EM>ny <EM>M</EM>nemonic</H3>
<H3>Description:</H3>
<P>Ignored </P>
<P>
<HR>

<P></P><A name=opt>
<H2>The opt PSEUDO OPCODE</H2></A>
<H3>Name: Assembler Options</H3>
<P>There are five permissible operands for this instruction:</P>
<UL>
  <LI>l - enable listing after <EM>opt nol</EM> 
  <LI>nol - disable listing until <EM>opt l </EM>or end of source code 
  <LI>c - calculate execution time (clock cycles) 
  <LI>noc - stop calculating execution time </LI></UL>
<UL>
  <LI>contc - continue calculating execution time </LI></UL>
<H2>
<HR>
<A name=org>The org PSEUDO OPCODE</H2></A>
<H3>Name: Origin</H3>
<H3>Syntax and examples (maybe):</H3><PRE>	org	value_to_set_program_counter_to

	org	$800	;not my preferred form
	org	MY_PROGRAM_START	;better form
	org	LAST_MEMORY_LOCATION-(LAST_PROGRAM_BYTE-FIRST_PROGRAM_BYTE);best but complex and has reference problems
</PRE>
<H3>Description:</H3>
<P>The org pseudo opcode allows the assembler's program counter to be set to a 
value. This is useful for locating your software and its elements (tables, ram, 
constants, etc) in useful (intelligent) locations within the memory space of the 
microcontroller.</P>
<P>In better multi-pass assemblers (not as12), the org statement is rarely used 
because the code is located at the link, and not during compilation. Since as12 
is a <EM>simple</EM> two-pass assembler, orgs must be used so that the code is 
compiled where it is supposed to.</P>
<H3>Notes:</H3>
<UL>
  <LI>When starting a new region of code, you can examine the s-record file and 
  see how org affects the construction of that file. 
  <LI>It is better to use the form <EM>org label</EM> than <EM>org constant</EM> 
  because the more constants that are buried within your code, the more 
  difficult it is to reuse. 
  <LI>The less orgs you use, the more reusable your code is. </LI></UL>
<H3>Related To:</H3>
<UL>
  <LI>program counter because this sets its value 
  <LI>rmb and its cousins because they change the program counter </LI></UL>
<H3>Things to look out for:</H3>
<UL>
  <LI>Always find out where the orgs are in a program. This is the first key to 
  understanding the program. </LI></UL>
<P>
<HR>
<A name=pag></A><A name=page>
<H2>The pag PSEUDO OPCODE</H2></A>
<P>
<H3>Name: Poor Aging Gophers</H3>
<P>Ignored</P>
<P>
<HR>

<P></P>
<H2><A name=redef></A>The redef PSEUDO OPCODE</H2>
<H3>Name: <EM>Redef</EM>ine</H3>
<P>Used to redefine first operand (which must be a label) to value of second 
operand (an expression)</P>
<P>Example:</P><PRE>foo     equ     10
        ldaa    #foo        ; Accumulator A gets value 10
        redef   foo 12
        ldab    #foo      ; Accumulator B gets value 12</PRE>
<H2>
<HR>
<A name=rmb></A>The rmb PSEUDO OPCODE</H2>
<H3>Name: <EM>R</EM>eserve <EM>M</EM>emory <EM>B</EM>ytes</H3>
<P>Equivalent to <EM>ds.b</EM> or <EM>ds, </EM>which is preferred.</P>
<P>
<HR>

<P></P>
<H2><A name=rmw></A>The rmw PSEUDO OPCODE</H2>
<H3>Name: <EM>R</EM>eserve <EM>M</EM>emory <EM>W</EM>ords</H3>
<P>Equivalent to <EM>ds.w</EM>.</P>
<P>
<HR>

<P></P>
<H2><A name=spc></A>The spc PSEUDO OPCODE</H2>
<H3>Name: <EM>Sp</EM>a<EM>c</EM>e</H3>
<P>Ignored</P>
<P>
<HR>

<P></P>
<H2><A name=ttl></A>The ttl PSEUDO OPCODE</H2>
<H3>Name: <EM>T</EM>it<EM>tl</EM>e</H3>
<P>Ignored</P>
<P>
<HR>

<P></P>
<H2><A name=zmb></A>The zmb PSEUDO OPCODE</H2>
<H3>Name: <EM>Z</EM>ero <EM>M</EM>emory <EM>B</EM>ytes</H3>
<P>Operand specifies number of bytes to allocate and fill with zero. Use is not 
recommended.</P></BODY></HTML>